package com.ovopark.firecar.adapter

import android.content.Context
import android.os.Handler
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.ovopark.firecar.R
import com.ovopark.firecar.bean.ArriveAddressBean
import com.ovopark.firecar.recyclerview.adapter.KingRecyclerViewAdapter
import com.ovopark.firecar.recyclerview.delegate.ItemViewDelegate
import com.ovopark.firecar.recyclerview.viewholder.BaseRecyclerViewHolder

class ArriveAddressAdapter(var mContext : Context,callback: ChooseAddressCallback) : KingRecyclerViewAdapter<ArriveAddressBean>(mContext) {
    lateinit var tvArriveAddress : TextView
    lateinit var handle : Handler
    interface ChooseAddressCallback{
        fun chooseAddress(arriveAddress : ArriveAddressBean?)
    }
    init {
        addItemViewDelegate(object : ItemViewDelegate<ArriveAddressBean>{
            override fun getItemViewLayoutId(): Int = R.layout.item_arrive_address

            override fun isForViewType(item: ArriveAddressBean?, position: Int): Boolean = true

            override fun convert(holder: BaseRecyclerViewHolder?, t: ArriveAddressBean?, position: Int) {
                tvArriveAddress = holder!!.getView(R.id.tv_arrive_address)
                tvArriveAddress.text = t?.APP_SHOW_NAME
                tvArriveAddress.setOnClickListener {
                    callback.chooseAddress(t)
                }

            }

        })
    }

    fun exchangeLayout(){
        tvArriveAddress.setTextColor(ContextCompat.getColor(mContext,R.color.white))
        tvArriveAddress.background = ContextCompat.getDrawable(mContext,R.drawable.bg_radius_blue)
    }

}